package com.hmall.searchService.listener;

import com.hmall.searchService.Constants.MqConstants;
import com.hmall.searchService.service.ItemService;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class ItemListener {

    @Autowired
    private ItemService itemService;

    /**
     * 上架消息接收
     *
     * @param id
     */
    //上架
    @RabbitListener(queues = MqConstants.ITEM_STATUS_UP_QUEUE)
    public void listenItemStatusUp(Long id) {
        itemService.insertItemById(id);
    }


    //下架
    @RabbitListener(queues = MqConstants.ITEM_STATUS_DOWN_QUEUE)
    public void listenItemStatusDown(Long id) {
        itemService.deletedItemById(id);
    }
}
